package org.hello.spring.persistence.dao.impl;

import java.util.List;

import org.hello.spring.persistence.dao.UserDao;
import org.hello.spring.persistence.entities.User;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

	public void save(User User) {
		getHibernateTemplate().save(User);

	}

	public void update(User User) {
		getHibernateTemplate().update(User);
	}

	public void delete(User User) {
		getHibernateTemplate().delete(User);
	}

	public User findById(Long userId) {
		List<?> list = getHibernateTemplate().find("from User where userId=?",
				userId);
		return (User) list.get(0);
	}

	public List<User> findAll() {
		List<User> list = getHibernateTemplate().find("from User");
		return list;
	}

}
